import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login/') // 路由懒加载
  },
  {
    path: '',
    // name: 'layout',
    // 路由懒加载
    component: () => import('@/views/Layout/'),
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('@/views/Home')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/My')
      },
      {
        path: '/video',
        name: 'video',
        component: () => import('@/views/Video')
      },
      {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/Qa')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/Search/')
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/Article/'),
    props: true // 开启 props 传参,把路由参数映射到 props 中
  },
  {
    path: '/user-profile',
    name: 'userprofile',
    component: () => import('@/views/user-profile/'),
    props: true // 开启 props 传参,把路由参数映射到 props 中
  }
]

const router = new VueRouter({
  routes
})

export default router
